/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package org.apli.haiam.ejb.entidades;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import net.sf.jasperreports.engine.JRDataSource;
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;

/**
 *
 * @author Informática
 */
@Entity
@Table(name = "cex_especialidad_medico")
@NamedQueries({
    @NamedQuery(name = "CexEspecialidadMedico.findAll", query = "SELECT c FROM CexEspecialidadMedico c")})
public class CexEspecialidadMedico implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "ces_ame_id")
    private Integer cesAmeId;
    @OneToMany(mappedBy = "cexEspecialidadMedico", fetch = FetchType.LAZY)
    @OrderBy("choOrden ASC")
    private List<CexHorario> cexHorarioList;
    @JoinColumn(name = "ces_id", referencedColumnName = "ces_id")
    @ManyToOne(fetch = FetchType.LAZY)
    private CexEspecialidad cexEspecialidad;
    @JoinColumn(name = "ame_id", referencedColumnName = "ame_id")
    @ManyToOne(fetch = FetchType.LAZY)
    private AdmMedico admMedico;
    //Lista de tipo net.sf.jasperreports.engine.JRDataSource para generar subreporte
    // de la entidad CexHorario

    public CexEspecialidadMedico() {
    }

    public CexEspecialidadMedico(Integer cesAmeId) {
        this.cesAmeId = cesAmeId;
    }

    public Integer getCesAmeId() {
        return cesAmeId;
    }

    public void setCesAmeId(Integer cesAmeId) {
        this.cesAmeId = cesAmeId;
    }

    public List<CexHorario> getCexHorarioList() {
        return cexHorarioList;
    }

    public void setCexHorarioList(List<CexHorario> cexHorarioList) {
        this.cexHorarioList = cexHorarioList;
    }

    public CexEspecialidad getCexEspecialidad() {
        return cexEspecialidad;
    }

    public void setCexEspecialidad(CexEspecialidad cexEspecialidad) {
        this.cexEspecialidad = cexEspecialidad;
    }

    public AdmMedico getAdmMedico() {
        return admMedico;
    }

    public void setAdmMedico(AdmMedico admMedico) {
        this.admMedico = admMedico;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (cesAmeId != null ? cesAmeId.hashCode() : 0);
        return hash;
    }

    public JRDataSource getCexHorarioListJasper() {
        return new JRBeanCollectionDataSource(cexHorarioList);
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof CexEspecialidadMedico)) {
            return false;
        }
        CexEspecialidadMedico other = (CexEspecialidadMedico) object;
        if ((this.cesAmeId == null && other.cesAmeId != null) || (this.cesAmeId != null && !this.cesAmeId.equals(other.cesAmeId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.apli.haiam.ejb.entidades.CexEspecialidadMedico[ cesAmeId=" + cesAmeId + " ]";
    }

}
